package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.entity.User;
import com.cskaoyan.bean.vo.BasePageData;
import com.cskaoyan.bean.vo.BaseParam;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("user/list")
    public BaseRespVo list(String username, String mobile, BaseParam param) {
        BasePageData data = userService.query(username,mobile,param);
        return BaseRespVo.ok(data);
    }

    /**
     * 如下是经历一番折腾后，实现的内容
     */
    /**
     * 根据id进行查询
     * @param id
     * @return
     */
    @RequestMapping("user/detail")
    public BaseRespVo detail(Integer id){
        User data = userService.queryid(id);
        return BaseRespVo.ok(data);
    }

    /**
     * **********************将原先git pull冲突的部分，迁移过来***************************
     */
    /**
     * 会员收藏部分
     *
     * @param userId
     * @param valueId
     * @param baseParam
     * @return
     */

    //http://localhost:8083/admin/collect/list?page=1&limit=20&sort=add_time&order=desc
    @RequestMapping("collect/list")
    public BaseRespVo collect(Integer userId, Integer valueId, BaseParam baseParam) {
        BasePageData users = userService.list(userId, valueId, baseParam);
        return BaseRespVo.ok(users);
    }

    /**
     * 会员足迹
     * @param userId
     * @param goodsId
     * @param baseParam
     * @return
     */
    //http://localhost:8083/admin/footprint/list?page=1&limit=20&sort=add_time&order=desc
    @RequestMapping("footprint/list")
    public BaseRespVo footprint(Integer userId, Integer goodsId, BaseParam baseParam) {
        BasePageData footprint = userService.footprint(userId, goodsId, baseParam);
        return BaseRespVo.ok(footprint);
    }


    /**
     * 搜索历史
     * @param userId
     * @param keyword
     * @param baseParam
     * @return
     */
    //http://localhost:8083/admin/history/list?page=1&limit=20&sort=add_time&order=desc
    @RequestMapping("history/list")
    public BaseRespVo history(Integer userId, String keyword, BaseParam baseParam) {
        BasePageData history = userService.history(userId, keyword, baseParam);
        return BaseRespVo.ok(history);
    }

    /**
     * 意见反馈
     * @param id
     * @param username
     * @param baseParam
     * @return
     */
    //http://localhost:8083/admin/feedback/list?page=1&limit=20&sort=add_time&order=desc
    @RequestMapping("feedback/list")
    public BaseRespVo feedback(Integer id, String username, BaseParam baseParam) {
        BasePageData feedback = userService.feedback(id, username, baseParam);
        return BaseRespVo.ok(feedback);
    }

    /**
     *
     * @param baseParam
     * @return
     */
    @RequestMapping("address/list")
    public BaseRespVo list( String name,Integer userId,BaseParam baseParam) {
        BasePageData basePageData = userService.list(name,userId,baseParam);
        return BaseRespVo.ok(basePageData);
    }


}
